package com.muatocroi.tornado;

import java.net.InetAddress;
import java.util.ArrayList;

import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.graphics.Color;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ScrollView;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.TabHost.TabSpec;

public class ControlerActivity extends TabActivity{
	
	public static final String STRSLIDE_SHOW = "Slide Show";
	public static final String STRSEND_FILE = "Send File";
	public static final String STRPOWER = "Power control";
	public static final String STRSCREEN = "Screen";
	public static final String STRSENDMICRO = "Send Micro";
	
	public static final String FunctionList[] = {STRSLIDE_SHOW, STRSCREEN, STRSEND_FILE, STRSENDMICRO, STRPOWER};
	
	private TabSpec tmpTab[];
	private Intent tmpIntent[];
	private int curTabIndex = 0;
	
	private Class FunClass[] = {SlideShowActivity.class, ScreenActivity.class,  SendFileActivity.class, SendAudioActivity.class ,PowerActivity.class};
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        setContentView(R.layout.activity_controler);
        setTab();
        //For tab animate, more memory
        //this.getTabHost().setOnTabChangedListener(new AnimatedTabHostListener(this.getTabHost()));
        
	}
	private TextView newTabView(String text) {
		TextView res = new TextView(getBaseContext());
		res.setText(text);
		res.setWidth(170);
		res.setGravity(Gravity.CENTER);
		res.setPadding(0, 5, 0, 5);
		return res;
	}
	private void setTab() {
		TabHost tabHost = getTabHost();

		int NumFunc = FunctionList.length;
		tmpTab = new TabSpec[NumFunc];
		tmpIntent = new Intent[NumFunc];

		for (int i = 0; i < NumFunc; i++) {
			tmpTab[i] = tabHost.newTabSpec(FunctionList[i]);
			tmpTab[i].setIndicator(newTabView(FunctionList[i]));

			tmpIntent[i] = new Intent(this, FunClass[i]);
			tmpIntent[i].addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
			tmpTab[i].setContent(tmpIntent[i]);
			tabHost.addTab(tmpTab[i]);
		}
	}
}
